﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication1
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DropDownList1.Items.Add("福建");
                DropDownList1.Items.Add("广东");
                DropDownList1.Items.Add("广西");
                DropDownList2.Items.Add("龙岩");
                DropDownList2.Items.Add("厦门");
                DropDownList2.Items.Add("漳州");
            }
        }

        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            string province = DropDownList1.SelectedValue;
            DropDownList2.Items.Clear();

            if (province == "福建")
            {
                DropDownList2.Items.Add("龙岩");
                DropDownList2.Items.Add("厦门");
                DropDownList2.Items.Add("漳州");
            }
            else if (province == "广东")
            {
                DropDownList2.Items.Add("深圳");
                DropDownList2.Items.Add("广州");
                DropDownList2.Items.Add("东莞");
            }
            else
            {
                DropDownList2.Items.Add("南宁");
                DropDownList2.Items.Add("桂林");
                DropDownList2.Items.Add("崇左");
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            if (ful.HasFile)
            {
                string fileName = ful.FileName;
                if (fileName.EndsWith(".jpg") || fileName.EndsWith(".png") || fileName.EndsWith(".jpeg"))
                {
                    string url = Server.MapPath("/img/" + fileName);
                    ful.SaveAs(url);
                    Image1.ImageUrl = "/img/" + fileName;
                    Image1.Visible = true;
                }
                else
                {

                }
            }
            else
            {

            }
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            this.Literal1.Text = $"用户名:{this.TextBox1.Text},性别：{RadioButtonList1.SelectedValue},爱好:{CheckBoxList1.Text},{DropDownList1.SelectedValue}省,{DropDownList2.SelectedValue}市,其他信息：{TextBox4.Text}";
        }
    }
}